package org.example.Day6.JDK8;

import java.util.*;
import java.util.stream.Stream;

public class SteamTest {
    public static void main(String[] args){
        //获取List 集合Stream流信息
        List<String> names = new ArrayList<>();
        Collections.addAll(names, "张三丰","张⽆忌","周芷若","赵敏","张强");
        Stream<String> stream = names.stream();
        stream.forEach(s -> System.out.println(s));


        //获取set Stream流
        Set<String> set = new HashSet<>();
        Collections.addAll(set,"刘德华","张曼⽟","蜘蛛精","⻢德","德玛⻄亚");
        Stream<String> stream1 = set.stream();
        stream1.filter(s -> s.contains("德")).forEach(s -> System.out.println(s));

        //获取map中的Stream流
        Map<String, Double> map = new HashMap<>();
        map.put("古⼒娜扎", 172.3);
        map.put("迪丽热巴", 168.3);
        map.put("⻢尔扎哈", 166.3);
        map.put("卡尔扎巴", 168.3);

//        Set<String> keys = map.keySet();
//        Stream<String> ks = keys.stream();
//
//        Collection<Double> values = map.values();
//        Stream<Double> vs = values.stream();

//        map.forEach((k,v)->{
//        System.out.println(k+"==>"+v);
//        }
//            );
        Set<Map.Entry<String,Double>> entries =map.entrySet();
        Stream<Map.Entry<String,Double>> kvs = entries.stream();
        kvs.filter(e -> e.getKey().contains("巴"))
                .forEach(e -> System.out.println(e.getKey()+"==>"+e.getValue()));

        //获取数组
        String[] names2 = {"张翠⼭", "东⽅不败", "唐⼤⼭", "独孤求败"};
        Stream<String> s1 = Arrays.stream(names2);
        Stream<String> s2 = Stream.of(names2);
    }
}
